#ifndef QUANTITY_H
#define QUANTITY_H

#include "Amount.h"


template <typename UnitType>
class Quantity
{
public :
    Quantity(const Amount& amount, const UnitType& unit)
        : amount(amount), unit(unit)
    {}

    bool operator==(const Quantity& rhs) const
    {
        return (this->getBaseAmount() == rhs.getBaseAmount());    
    }    
    bool operator!=(const Quantity& rhs) const
    {
        return !( *this == rhs );
    }
    Quantity operator+(const Quantity& rhs) const
    {
        Amount amount = this->getBaseAmount() + rhs.getBaseAmount();    
        return Quantity(amount, unit.getBaseUnit());
    }

protected:
    Amount getBaseAmount() const
    {
        return amount * unit.getRatePerBaseUnit();
    }

private:
    Amount amount;
    const UnitType& unit;
};
#endif
